import ajax from "./ajax"
import mockAjax from "./mockAjax"

//获取三级列表信息
export const getLevelListData = () =>
  ajax.get("/api/product/getBaseCategoryList")

//获取搜索页面信息
export const getListSearch = (option) => ajax.post("/api/list", option)

//获取详情页面信息
export const getListDetail = (skuid) => ajax.get("/api/item/" + skuid)

//获取轮播图信息
export const getBannerData = () => mockAjax.get("/banner")

//获取楼层信息
export const getFloorData = () => mockAjax.get("floor")

//添加到购物车（没有经过vuex）
export const addOrUpdateCart = (skuId, skuNum) =>
  ajax.post(`/api/cart/addToCart/${skuId}/${skuNum}`)

//获取购物车数据（没有经过vuex）
export const getCartData = () => ajax.get("/api/cart/cartList")

//修改购物车数据
export const updateCartData = (skuId, isChecked) =>
  ajax.get(`/api/cart/checkCart/${skuId}/${isChecked}`)

//批量修改购物车选中与否
export const updateCartEveryData = (skuIdList, isChecked) =>
  ajax.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)

//删除单个商品
export const removeCartData = (skuId) =>
  ajax.delete(`/api/cart/deleteCart/${skuId}`)

//删除多个商品
export const removeAllCartData = (selectedObj) =>
  ajax.delete("/api/cart/batchDeleteCart", selectedObj)

//获取验证码
export const getcode = (phone) =>
  ajax.get(`/api/user/passport/sendCode/${phone}`)

//注册账号的请求
export const registerUser = (user) =>
  ajax.post("/api/user/passport/register", user)

//登录验证请求
export const getLoginCheck = (user) =>
  ajax.post("/api/user/passport/login", user)

//退出登录请求
export const deleteUserData = () => ajax.get("/api/user/passport/logout")

//获取用户购物地址
export const getUserAddress = () =>
  ajax.get("/api/user/userAddress/auth/findUserAddressList")

//获取用户订单信息
export const getUserOrderData = () => ajax.get("/api/order/auth/trade")

//跳转至订单详情页(提交订单)
export const commitOrder = (tradeNo, query) =>
  ajax.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, query)

//获取支付二维码
export const getPayOrder = (orderId) =>
  ajax.get(`/api/payment/weixin/createNative/${orderId}`)

//查询支付是否成功
export const getQueryPayStatus = (orderId) =>
  ajax.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
